blob: 093d9301a310bc3c53c7dc3eeb0e08f24a00a302 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
import { ReactNode } from 'react';
import { HeaderV2 } from '@/components/layout/HeaderV2';
import { SiteFooter } from '@/components/layout/Footer';
import { getServerSession } from "next-auth";
import { authOptions } from "@/app/api/auth/[...nextauth]/route";
import { verifyNonsapPermission } from "@/lib/nonsap/auth-service";
import { PermissionChecker } from "@/components/common/permission-checker";
export default async function EvcpLayout({ children }: { children: ReactNode }) {
const session = await getServerSession(authOptions);
let isAuthorized = true;
let authMessage = "";
// Skip permission check if environment variable is set
const skipPermissionCheck = process.env.SKIP_ORACLE_PERMISSION_CHECK === 'true';
// Only check permission if user is logged in and check is not skipped
if (session?.user?.id && !skipPermissionCheck) {
try {
const result = await verifyNonsapPermission(
parseInt(session.user.id),
// ['SEARCH']
[] // 아무런 실제 권한이 없어도, 등록된 상태라면 화면에 'SEARCH' 권한이 있는것처럼 동작하게 해달라고 함. (김희은 프로)
);
isAuthorized = result.authorized;
authMessage = result.message || "";
} catch (error) {
console.error("Permission check failed:", error);
// Default to true in case of error to avoid blocking access due to system error
// but logic could be changed to false for strict security
isAuthorized = true;
authMessage = "Permission check error";
}
}
return (
<div className="relative flex min-h-svh flex-col bg-background">
{/* <div className="relative flex min-h-svh flex-col bg-slate-100 "> */}
<HeaderV2 />
{!skipPermissionCheck && (
<PermissionChecker authorized={isAuthorized} message={authMessage} />
)}
<main className="flex flex-1 flex-col">
<div className='container-wrapper'>
{children}
</div>
</main>
<SiteFooter/>
</div>
);
}
|